﻿#ifndef WEBVIEW_H
#define WEBVIEW_H

#include <QWebEnginePage>
#include <QWebEngineView>
#include <QWidget>

#include "webpage.h"
#include "mainwindow.h"
#include "customprogressbar.h"
#include "globaldata.h"
#include "urlchecker.h"
#include "recordhistorythread.h"

class WebPage;
class MainWindow;
class CustomProgressBar;
class URLChecker;

class WebView : public QWebEngineView
{
    Q_OBJECT
public:
    WebView(QWidget *parent = nullptr);

    void setWebPage(WebPage *page);

    QWebEngineView * createWindow(QWebEnginePage::WebWindowType type) override;



    QIcon favIcon() const;

    //
    void reload();
signals:
    void loadStartedWebView();
    void loadProgressWebView(int val);
    void loadFinishedWebView(bool success);

    // 图标更新信号
    void favIconChanged(QIcon icon);
    // 启用应用某些功能的信号
    void webActionEnabledChanged(QWebEnginePage::WebAction webAction, bool enabled);

    // 不安全url检测
    void urlNotSafe(QString url);

    // url改变
    void urlChanged(QUrl url);

    //检测url是否已经被收藏
    void checkUrlIsMark(QString url);

private:
    // 加载进度
    int m_progress;
    CustomProgressBar *progress;
};

#endif // WEBVIEW_H
